package com.xmmj.baselibrary.utils.viewadapter.view

import androidx.databinding.BindingAdapter
import android.view.View

@BindingAdapter(value = ["onClickListener"], requireAll = false)
fun setOnClickListener(view: View, onClickListener: View.OnClickListener) {
    onClickListener.let {
        view.setOnClickListener(it)
    }

}

@BindingAdapter(value = ["onLongClickListener"], requireAll = false)
fun onLongClickListener(view: View, onLongClickListener: View.OnLongClickListener) {
    onLongClickListener.let {
        view.setOnLongClickListener(it)
    }
}

@BindingAdapter(value = ["isSelected"], requireAll = false)
fun setSelected(view: View, isSelected: Boolean) {
    view.isSelected = isSelected
}

@BindingAdapter(value = ["android:visibility"], requireAll = false)
fun setVisibility(view: View, visibility: Boolean) {
    view.visibility = if (visibility) View.VISIBLE else View.GONE
}

@BindingAdapter(value = ["android:invisible"], requireAll = false)
fun setInVisible(view: View, invisible: Boolean) {
    view.visibility = if (invisible) View.INVISIBLE else View.VISIBLE
}
